package com.korovyansk.mapsproto.beans;

public class Position{
	
	public final int x;
	public final int y;
	
	@Override
	public boolean equals(Object o) {
		if(o != null && o instanceof Position){
			Position otherPosition = (Position)o;
			return x == otherPosition.x && y == otherPosition.y;
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return x * 3 + y * 5;
	}
	
	@Override
	public String toString() {
		return "(" + x + "," + y + ")";
	}
	
	public boolean isInRectangle(final Position lt, final Size size){
		return x >= lt.x && x < lt.x + size.width && y >= lt.y && y < lt.y + size.height;
	}
	
	public Position(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
}